package Leetcode.array;

public class MaxProfit {
    public int maxProfit(int[] prices) {
        if(prices.length<2)
            return 0;

        int sum=0;

        for (int i=1;i<prices.length;i++){
            if (prices[i]>prices[i-1]){
                sum=sum+prices[i]-prices[i-1];
            }
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] a={2,1};
        MaxProfit maxProfit=new MaxProfit();
        System.out.println(maxProfit.maxProfit(a));

    }
}
